<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .zzc{
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            z-index: 10;
            display: none;
            background-color: rgb(0, 0, 0,0.3);
        }
        .mtk{
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            margin: auto;
            width: 400px;
            height: 400px;
            z-index: 11;
            background-color: pink;
            box-sizing: border-box;
            display: none;
        }
        p{
            margin-left: 80px;
        }
        .phone{
            margin-top: 100px;
            
        }
    </style>
</head>
<body>
    <button onclick="show()">登录</button>
    <!-- <div class="zzc"></div> -->
    <div class="mtk">
        <p>手机号：<input type="text" class="phone"></p>
        <p>验证码：<input type="text" class="yzm"><span></span></p>
        <p><button onclick="dl()">登录</button>&nbsp;<button onclick="no()">关闭</button></p>
    </div>
</body>
</html>
<script>
    var zzc=document.querySelector('.zzc')
    var mtk=document.querySelector('.mtk')
    var phone=document.querySelector('.phone')
    var yzm=document.querySelector('.yzm')
    var span=document.querySelector('span')
    function show(){
        mtk.style.display='block'
        zzc.style.display='block'
    }
    function no(){
        mtk.style.display='block'
        zzc.style.display='block'
    }
    function getNum(){
        var sjs=Math.floor(Math.random()*(9999-1000)+1000)
        return sjs
    }
    var sjs=getNum();
    span.innerHTML=sjs
    function set(arr){
        localStorage.setItem('data',JSON.stringify(arr))
    }
    function get(){
        var a= localStorage.getItem('data')
        if(a!=null){
            return JSON.parse(a)
        }else{
            return[]
        }
    }
    function dl(){
        if(phone.value.trim()==''&&yzm.value.trim()==''){
            alert('内容不能为空')
        }else if(yzm.value.trim()!=sjs){
            alert('验证码错误')
        }else{
            alert('登录成功')
            location.href='./index.html'
        }
    }
</script>